package com.liushuang.waiwaiim.controller.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.ListView;

import com.liushuang.waiwaiim.R;
import com.liushuang.waiwaiim.controller.adapter.InviteAdapter;
import com.liushuang.waiwaiim.model.Model;
import com.liushuang.waiwaiim.model.bean.InvationInfo;

import java.util.List;

public class InviteActivity extends AppCompatActivity {

    private ListView mLvInvite;
    private InviteAdapter mInviteAdapter;
    private InviteAdapter.OnInviteListener mOnInviteListener = new InviteAdapter.OnInviteListener() {
        @Override
        public void onAccept(InvationInfo invationInfo) {

        }

        @Override
        public void onReject(InvationInfo invationInfo) {

        }

        @Override
        public void onInviteAccept(InvationInfo invationInfo) {

        }

        @Override
        public void onInviteReject(InvationInfo invationInfo) {

        }

        @Override
        public void onApplicationAccept(InvationInfo invationInfo) {

        }

        @Override
        public void onApplicationReject(InvationInfo invationInfo) {

        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_invite);

        initView();

        initData();
    }

    private void initData() {

        mInviteAdapter = new InviteAdapter(this, mOnInviteListener);
        mLvInvite.setAdapter(mInviteAdapter);
        refresh();
    }

    private void refresh() {
        //获取数据库中的所有邀请信息
        List<InvationInfo> invitations = Model.getInstance().getDbManager().getInviteTableDao().getInvitations();
        //刷新适配器
        mInviteAdapter.refresh(invitations);
    }

    private void initView() {
        mLvInvite = findViewById(R.id.lv_invite);
    }
}